package com.plian.system.wrapper.zp;

import com.plian.Tools.DateUtil;
import com.plian.system.dto.zp.ZpPersonInfoDTO;
import com.plian.system.entity.hr.staff.StaffFiles;
import com.plian.system.entity.zp.ZpPersonInfo;
import com.plian.system.mybatis.support.BaseWrapper;
import com.plian.system.vo.zp.ZpPersonInfoVO;
import com.plian.system.vo.zzd.sys.PersonnelSimpleInfoVO;
import com.plian.system.wrapper.util.CacheWrapperUtil;
import com.plian.system.wrapper.util.WrapperUtil;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

import static com.plian.system.wrapper.util.WrapperConstant.*;

/**
 * 招聘人员信息包装类,返回视图层所需的字段
 *
 * @author gangan
 * @since 2019-09-29
 */
@Mapper(componentModel = SPRING, uses = {CacheWrapperUtil.class, WrapperUtil.class})
public interface ZpPersonInfoWrapper extends BaseWrapper<ZpPersonInfo, ZpPersonInfoDTO, ZpPersonInfoVO> {

	@Override
	@Mappings(value = {
			@Mapping(source = "createUser", target = "createUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "approvedUser", target = "approvedUserName", qualifiedByName = USER_ID_TO_NAME),
			@Mapping(source = "documentTypeId", target = "documentTypeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "genderId", target = "genderName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "nationId", target = "nationName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "politicCountenanceId", target = "politicCountenanceName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "nationalityId", target = "nationalityName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "maritalStatusId", target = "maritalStatusName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "educationalId", target = "educationalName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "degreeId", target = "degreeName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "healthConditionId", target = "healthConditionName", qualifiedByName = DICT_CODE_TO_NAME),
			@Mapping(source = "birthday", target = "birthdayStr", dateFormat = DateUtil.PATTERN_DATE),
			@Mapping(source = "staffCode", target = "staffCode", qualifiedByName = DECRYPT_BASE64_DATA),
			@Mapping(source = "documentNumber", target = "documentNumber", qualifiedByName = DECRYPT_BASE64_DATA)
	})
	ZpPersonInfoVO entityToVO(ZpPersonInfo entity);


	@Mappings(value = {
			@Mapping(source = "jobNameId", target = "jobName")
	})
	PersonnelSimpleInfoVO entityToPersonnelSimpleInfoVO(StaffFiles entity);

	List<PersonnelSimpleInfoVO> entityToPersonnelSimpleInfoVO(List<StaffFiles> entityList);
}
